package com.imooc.pan.server.modules.user.converter;

import com.imooc.pan.server.modules.file.entity.RPanUserFile;
import com.imooc.pan.server.modules.user.context.*;
import com.imooc.pan.server.modules.user.entity.RPanUser;
import com.imooc.pan.server.modules.user.po.*;
import com.imooc.pan.server.modules.user.vo.UserInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 用户模块实体转化工具类
 */

@Mapper(componentModel = "spring")
public interface UserConverter {
    UserRegisterContext userRegisterPO2UserRegisterContext(UserRegisterPO userRegisterPO);

    @Mapping(target = "password", ignore = true)
    RPanUser userRegisterContext2RPanUser(UserRegisterContext userRegisterContext);


    UserLoginContext userLoginPO2UserLoginContext(UserLoginPO userLoginPO);

    CheckUsernameContext checkUsernamePO2CheckUsernameContext(CheckUsernamePO checkUsernamePO);

    CheckAnswerContext checkAnswerPO2CheckAnswerContext (CheckAnswerPO checkAnswerPO);

   ResetPasswordContext resetPasswordPO2ResetPasswordContext(ResetPasswordPO resetPasswordPO);

   ChangePasswordContext changePasswordPO2ChangePasswordContext(ChangePasswordPO changePasswordPO);


   @Mapping(source = "rPanUser.username", target = "username")
   @Mapping(source = "rPanUserFile.fileId", target = "rootFileId")
   @Mapping(source = "rPanUserFile.filename", target = "rootFilename")
   UserInfoVO assembleUserInfoVO(RPanUser rPanUser, RPanUserFile rPanUserFile);

}
